package org.example.common.config;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer code;
    private String message;
    private Object data;


    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }


    public Result(Integer code) {
        this.code = code;
    }

    public static Result ok() {
        return new Result(200, "操作成功");
    }

    public static Result ok(Object data) {
        return new Result(200, "操作成功", data);
    }

    public static Result fail( String message, Object data) {
        return new Result(500, message, data);
    }

    public static Result fail(String  message) {
        return new Result(500, message);
    }

    public static Result error(Integer code, String message) {
        return new Result(code, message);
    }

}
